package com.qingxin.web.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qingxin.park.entity.Company;
import com.qingxin.park.entity.WellProduct;
import com.qingxin.park.service.CompanyService;
import com.qingxin.park.service.WellProductService;
import com.qingxin.sys.action.BaseAction;
import com.qingxin.sys.mvc.PageParam;


/**
 * 特色产品
 * @author Administrator
 *
 */

@Controller
public class ProductsAction extends BaseAction {
	@Autowired
	private WellProductService productService;
	@Autowired
	private CompanyService companyService;
	

	@RequestMapping(value="/c/products.do", method=RequestMethod.GET)
	public String policy_index(ModelMap model, HttpServletRequest request){
		model.put("model", "products");
		return "cms/products";
	}

	@RequestMapping(value="/c/list_products.json", method={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Object list_policy(PageParam pageParam,String type,HttpServletRequest request){
		pageParam.setPagesize(12);
		return productService.list(pageParam,type, request);
	}
	
	
	@RequestMapping(value="/c/pdtDetail.do", method=RequestMethod.GET)
	public String pdtDetail(ModelMap model, String id, HttpServletRequest request){
		model.put("model", "products");
		WellProduct wellProduct = productService.get(id);
		model.put("pdt", wellProduct);
		if(wellProduct != null){
			Company company = companyService.get(wellProduct.getCompanyid());
			model.put("company", company);
		}
		
		return "cms/pdt_detail";
	}
	
	
}
